<?php
// No direct access
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');


jimport('joomla.html.pane');
$tabsMain = JPane::getInstance('Tabs', array('startOffset'=>0));

$document =& JFactory::getDocument();

$document->addStyleSheet( NGCOM_URL.'/assets/js/popup/popup.css' );
$document->addStyleSheet( NGCOM_URL.'/assets/css/ngmenu.css' );
$document->addScript( NGCOM_URL.'/assets/js/popup/struct.js' );
$document->addScript( NGCOM_URL.'/assets/js/popup/popup.js' );
$document->addScript( NGCOM_URL.'/assets/js/ngmenu.js' );
$document->addScript( NGCOM_URL.'/assets/js/functions.js' );
$document->addScript( NGCOM_URL.'/assets/jscolor/jscolor.js' );

require_once(NGCOM_PATH.DS.'helpers'.DS.'ngmenu.php');
require_once(NGCOM_PATH.DS.'assets'.DS.'includes'.DS.'preview.inc.php');

?>
<script type="text/javascript">
	window.addEvent('domready', function() { $('jform_font_family').addEvent('change', function(e) { e.stop(); var url = 'index.php?option=com_ngmenu&task=changeweightlist&format=raw'; var x = new Request({ url: url, data: 'ngvalue='+encodeURIComponent(document.getElementById('jform_font_family').value)+'&item_id=0', method: 'post', onSuccess: function(r){ if(r.length){ var v, def; var w = document.getElementById('jformfont_weight'); w.options.length = 0; var rows = r.split(';'); for (var i=0;i<rows.length;i++){ def = (i==0) ? true : false; v = rows[i].split(':'); w.options[i] = new Option(v[1], v[0], def, false); } }}	}).send(); }); })
</script>
<style>
fieldset label {
	color: #146295;
	font-size: 1em;
}
div.current select {
	margin-bottom: 0px;
}
div.current label {
	margin-top: 5px;
}
</style>
<form action="<?php echo JRoute::_('index.php?option=com_ngmenu&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="ngmenu-form">
<?php
	echo $tabsMain->startPane( 'mainPane' );
	echo $tabsMain->startPanel( JText::_('COM_NGMENU_TAB_COMMON'), 'menu_common' );
?>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_COMMON' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('common') as $field){
			if($field->name == 'jform[is_horizontal]') {
				$style = ($field->value == '0') ? 'style="display:none;"' : '';
				echo (($begin) ? '' : '</li>');
				echo '<li>'; echo $field->label; echo $field->input; echo '</li>';
				echo '<li><div class="ngoptions" id="orientation-mode" '.$style.'><ul>';
				$begin2 = true;
				foreach($this->form->getFieldset('orientation-options') as $optionfield){
					if($optionfield->title){
						echo (($begin2) ? '<li class="ngoptions">' : '</li><li class="ngoptions">');
						echo $optionfield->label; echo $optionfield->input;
					}else{
						echo $optionfield->input;
					}
					$begin2 = false;
				}
				echo '</li></ul></div>';
			}elseif($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
			$begin = false;
		}
		echo '</li>';
?>
		</ul>
	</fieldset>
<?php
	echo $tabsMain->endPanel();
	echo $tabsMain->startPanel( JText::_('COM_NGMENU_TAB_EXTENDED'), 'menu_extended' );
?>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_EXTENDED' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('extended') as $field){
			if($field->name == 'jform[keystrokes_support_create]') {
				$style = ($field->value == '0') ? 'style="display:none;"' : '';
				echo (($begin) ? '' : '</li>');
				echo '<li>'; echo $field->label; echo $field->input; echo '</li>';
				echo '<li><div class="ngoptions" id="key-mode" '.$style.'><ul>';
				$begin2 = true;
				foreach($this->form->getFieldset('key-options') as $optionfield){
					if($optionfield->title){
						echo (($begin2) ? '<li class="ngoptions">' : '</li><li class="ngoptions">');
						echo $optionfield->label; echo $optionfield->input;
					}else{
						echo $optionfield->input;
					}
					$begin2 = false;
				}
				echo '</li></ul></div>';
			}elseif($field->name == 'jform[main_arrow_image_create]'){
				$style = ($field->value == '0') ? 'style="display:none;"' : '';
				echo (($begin) ? '' : '</li>');
				echo '<li>'; echo $field->label; echo $field->input; echo '</li>';
				echo '<li><div class="ngoptions" id="main-arrow-mode" '.$style.'><ul>';
				$begin2 = true;
				foreach($this->form->getFieldset('main-arrow-options') as $optionfield){
					if($optionfield->title){
						echo (($begin2) ? '<li class="ngoptions">' : '</li><li class="ngoptions">');
						echo $optionfield->label; echo $optionfield->input;
					}else{
						echo $optionfield->input;
					}
					$begin2 = false;
				}
				echo '</li></ul></div>';
			}elseif($field->name == 'jform[main_separator_create]'){
				$style = ($field->value == '0') ? 'style="display:none;"' : '';
				echo (($begin) ? '' : '</li>');
				echo '<li>'; echo $field->label; echo $field->input; echo '</li>';
				echo '<li><div class="ngoptions" id="main-separator-mode" '.$style.'><ul>';
				$begin2 = true;
				foreach($this->form->getFieldset('main-separator-options') as $optionfield){
					if($optionfield->title){
						echo (($begin2) ? '<li class="ngoptions">' : '</li><li class="ngoptions">');
						echo $optionfield->label; echo $optionfield->input;
					}else{
						echo $optionfield->input;
					}
					$begin2 = false;
				}
				echo '</li></ul></div>';
			}elseif($field->name == 'jform[effect_transparency_create]'){
				$style = ($field->value == '0') ? 'style="display:none;"' : '';
				echo (($begin) ? '' : '</li>');
				echo '<li>'; echo $field->label; echo $field->input; echo '</li>';
				echo '<li><div class="ngoptions" id="transparency-mode" '.$style.'><ul>';
				$begin2 = true;
				foreach($this->form->getFieldset('transparency-options') as $optionfield){
					if($optionfield->title){
						echo (($begin2) ? '<li class="ngoptions">' : '</li><li class="ngoptions">');
						echo $optionfield->label; echo $optionfield->input;
					}else{
						echo $optionfield->input;
					}
					$begin2 = false;
				}
				echo '</li></ul></div>';
			}elseif($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
//			echo $field->name;
			$begin = false;
		}
		echo '</li>';

?>
		</ul>
	</fieldset>
<?php
	echo $tabsMain->endPanel();
	echo $tabsMain->startPanel( JText::_('COM_NGMENU_TAB_BACKGROUND'), 'menu_bg' );
?>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_BACKGROUND_MENU' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('background') as $field){
			if($field->name == 'jform[menu_back_image_create]') {
				$style = ($field->value == '0') ? 'style="display:none;"' : '';
				echo (($begin) ? '' : '</li>');
				echo '<li>'; echo $field->label; echo $field->input; echo '</li>';
				echo '<li><div class="ngoptions" id="menu-image-mode" '.$style.'><ul>';
				$begin2 = true;
				foreach($this->form->getFieldset('menu-image-options') as $optionfield){
					if($optionfield->title){
						echo (($begin2) ? '<li class="ngoptions">' : '</li><li class="ngoptions">');
						echo $optionfield->label; echo $optionfield->input;
					}else{
						echo $optionfield->input;
					}
					$begin2 = false;
				}
				echo '</li>';
				echo '</ul></div>';
			}elseif($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
			$begin = false;
		}
		echo '</li>';
?>
		</ul>
	</fieldset>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_BACKGROUND_ITEMS' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('background-items') as $field){
			if($field->name == 'jform[item_back_image_create]') {
				$style = ($field->value == '0') ? 'style="display:none;"' : '';
				echo (($begin) ? '' : '</li>');
				echo '<li>'; echo $field->label; echo $field->input; echo '</li>';
				echo '<li><div class="ngoptions" id="item-image-mode" '.$style.'><ul>';
				$begin2 = true;
				foreach($this->form->getFieldset('item-image-options') as $optionfield){
					if($optionfield->title){
						echo (($begin2) ? '<li class="ngoptions">' : '</li><li class="ngoptions">');
						echo $optionfield->label; echo $optionfield->input;
					}else{
						echo $optionfield->input;
					}
					$begin2 = false;
				}
				echo '</li>';
				echo '</ul></div>';
			}elseif($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
			$begin = false;
		}
		echo '</li>';
?>
		</ul>
	</fieldset>
<?php
	echo $tabsMain->endPanel();
	echo $tabsMain->startPanel( JText::_('COM_NGMENU_TAB_BORDER'), 'menu_border' );
?>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_BORDER_MENU' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('menu-border-settings') as $field){
			if($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
			$begin = false;
		}
		echo '</li>';
?>
		</ul>
	</fieldset>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_BORDER_ITEMS' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('item-border-settings') as $field){
			if($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
			$begin = false;
		}
		echo '</li>';
?>
		</ul>
	</fieldset>
<?php
	echo $tabsMain->endPanel();
	echo $tabsMain->startPanel( JText::_('COM_NGMENU_TAB_LABEL'), 'menu_label' );
?>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_LABEL_TEXT_SETTINGS' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('label-settings') as $field){
			if($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
			$begin = false;
		}
		echo '</li>';
?>
		</ul>
	</fieldset>
<?php
	echo $tabsMain->endPanel();
	echo $tabsMain->startPanel( JText::_('COM_NGMENU_TAB_SPACING'), 'menu_spacing' );
?>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_ITEM_SPACING' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('item-spacing') as $field){
			if($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
			$begin = false;
		}
		echo '</li>';
?>
		</ul>
	</fieldset>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'COM_NGMENU_SECTION_ITEM_PADDING' ); ?></legend>
		<ul class="adminformlist">
<?php
		$begin = true;
		foreach($this->form->getFieldset('item-padding') as $field){
			if($field->title){
				echo (($begin) ? '<li>' : '</li><li>');
				echo $field->label; echo $field->input;
			}else{
				echo $field->input;
			}
			$begin = false;
		}
		echo '</li>';
?>
		</ul>
	</fieldset>
<?php
	echo $tabsMain->endPanel();
	echo $tabsMain->endPane();
?>
	<div>
		<input type="hidden" name="task" value="ngmenu.edit" />
		<input type="hidden" name="color_target_id" value="" />
		<input type="hidden" name="color_target_name" value="" />
		<?php echo JHtml::_('form.token'); ?>
	</div>
</form>
